<%--
  Created by IntelliJ IDEA.
  User: user
  Date: 2023/3/29
  Time: 15:48
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <title>Title</title>
</head>
<body>
<form action="userLogin" method="post">
    用户名：<input type="text" name="username">
    <br>
    密码:<input type="password" name="userpwd">
    <br>
    <button>登录</button>
</form>
<button id="bt1">获取笑话</button>
<div id="dv1"></div>
</body>
<script>
    var bt1=document.getElementById("bt1");
    bt1.onclick=function () {
        var ajaxRequest=new XMLHttpRequest();
        ajaxRequest.open("get","https://autumnfish.cn/api/joke/list?num=3");
        ajaxRequest.send();
        ajaxRequest.onreadystatechange=function (response) {
            console.log(response)
            if(ajaxRequest.readyState==4){
                console.log(ajaxRequest.responseText)
                document.getElementById("dv1").innerHTML=ajaxRequest.responseText
            }

        }

    }




</script>
</html>
